
#from django.newforms import form_for_model
from django.newforms import ModelForm
from django import newforms as forms
from django.contrib.auth.models import User
from models import Project
from models import Task

BUG_RESOLUTION_CHOICES = (
    ('Fixed', 'Fixed'),
    ('Canceled', 'Canceled'),
    ('Invalid', 'Invalid'),
    ('Sameas', 'Sameas'),
)

FEATURE_RESOLUTION_CHOICES = (
    ('Implemented', 'Implemented'),
    ('Denided', 'Denided'),
    ('Invalid', 'Invalid'),
    ('Sameas', 'Sameas'),
)


class TaskForm(ModelForm): 
    project =  forms.ModelChoiceField(Project.objects.all(), widget=forms.HiddenInput)
    kind =  forms.CharField(widget=forms.HiddenInput)
    status =  forms.CharField(widget=forms.HiddenInput)
    summary = forms.CharField(widget=forms.TextInput(attrs={'size':'80'}))
    description = forms.CharField(widget=forms.Textarea(attrs={'cols':'61','rows':'5'}))
    reporter = forms.ModelChoiceField(User.objects.all(), widget=forms.HiddenInput)
    owner = forms.ModelChoiceField(User.objects.all(), empty_label=None)
    class Meta:
        model = Task


class HistoryForm(TaskForm):
    #task =  forms.ModelChoiceField(Task.objects.all(), widget=forms.HiddenInput)
    comment = forms.CharField(widget=forms.Textarea(attrs={'cols':'61','rows':'5'}), required=False)


class TaskBugForm(TaskForm):
    comment = forms.CharField(widget=forms.Textarea(attrs={'cols':'61','rows':'5'}), required=False)
    resolution  = forms.ChoiceField(choices=BUG_RESOLUTION_CHOICES)

class TaskFeatureForm(TaskForm):
    comment = forms.CharField(widget=forms.Textarea(attrs={'cols':'61','rows':'5'}), required=False)
    resolution  = forms.ChoiceField(choices=FEATURE_RESOLUTION_CHOICES)

#class TaskForm(forms.Form):
#    name = forms.CharField(
#                widget=forms.TextInput(attrs={'class':'special'}))
#    url = forms.URLField()
#    
#	progect = models.ForeignKey('Project', verbose_name='')
#    kind = models.CharField(max_length=8, choices=KIND_CHOICES)  
#    summary = models.CharField(max_length=64, verbose_name='')
#    description = models.TextField(blank=True, verbose_name='')
#    severity = models.CharField(max_length=8, choices=SEVERITY_CHOICES)  
#    date = models.DateTimeField(auto_now_add=True)